package ca.nfb.media.nfbPlayer.views
{
	import ca.turbulent.media.Pyro;
	import ca.turbulent.media.events.PyroEvent;
	
	import ca.nfb.media.nfbPlayer.ComModule;
	import flash.display.MovieClip;
	import flash.events.Event;
	import ca.turbulent.media.events.StatusUpdateEvent;
	
	public class Warnings extends NFBPlayerView
	{
		public var wasShowing:Boolean = false;
		public var lang:String = ComModule.getLang();
		
		public function Warnings()
		{
			super();
			this.lockUI(true, [this]);
			hideWarningMessage();
			lang = ComModule.getLang();
		}
		
		
		public function showWarning(warningType:String):void
		{
			lang = ComModule.getLang();
			try
			{
				this.visible = true;
				var wt:String;
				switch(warningType)
				{
					case "PG":
					case "PG-13":
					case "R":
					case "NC-17":
					case "M":
					case "Mature":
					case "MATURE":
					case "mature":
					wt = "mature";
					break;
					
					case "V":
					case "v":
					case "violence":
					case "Violence":
					case "VIOLENCE":
					wt = "violence";
					break;
					
					case "N":
					case "Nudity":
					case "NUDITY":
					case "nudity":
					case "nudité":
					case "Nudité":
					case "NUDITÉ":
					wt = "nudity";
					break;
				}
				
				switch (wt)
				{
					case "violence":
					lang.toLowerCase() == "fr" ? this.gotoAndStop("violence_fr") : this.gotoAndStop("violence_en");
					break;
					
					case "nudity":
					lang.toLowerCase() == "fr" ? this.gotoAndStop("nudity_fr") : this.gotoAndStop("nudity_en");
					break;
					
					case "mature":
					lang.toLowerCase() == "fr" ? this.gotoAndStop("mature_fr") : this.gotoAndStop("mature_en");
					break;
					
				}
				
				if (wt == "violence" || wt == "nudity" || wt == "mature")
				{
					wasShowing = true;
					this.visible = true;
				}
				else
				{
					wasShowing = false;
					this.visible = false;	
				}
				
				
			}
			catch(err:Error)
			{
				;
			}	
		}
		
		override protected function streamStarted(evt:PyroEvent):void 
		{ 
			hideWarningMessage();
		}
		
		override protected function streamStatusUpdated(evt:StatusUpdateEvent):void 
		{ 
			switch(player.status)
			{
				case Pyro.STATUS_PLAYING:
				hideWarningMessage();
				break;
			}
		}
		
		override protected function coreStateUpdated(evt:Event=null):void
		{
			switch (core.currentState)
			{
				case NFBPlayer.PREVIEW_IMAGE_STATE:
				break
				
				default:
				hideWarningMessage();
				break;
			}
		}
		
		public function hideWarningMessage():void
		{
			this.visible = false;
		}
		
	}
}